package com.example.apiservice.client.fallback;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.apiservice.client.TeacherClient;
import com.example.common.domain.Result;
import com.example.common.domain.dto.SaveSection;
import com.example.common.domain.pojo.*;
import com.example.common.domain.vo.QuestionVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

@Slf4j
public class TeacherClientFallbackFactory implements FallbackFactory<TeacherClient> {
    @Override
    public TeacherClient create(Throwable cause) {
        return new TeacherClient() {
            @Override
            public Result<Void> saveOutline(CourseOutline outline) {
                return null;
            }

            @Override
            public Result<Void> saveSection(SaveSection save) {
                return null;
            }

            @Override
            public Result<Void> saveHomework(Homework homework) {
                return null;
            }

            @Override
            public Result<Void> saveQuestion(Question question) {
                return null;
            }

            @Override
            public Result<Void> saveQuestions(List<Question> questions) {
                return null;
            }

            @Override
            public Result<Void> UpdateSections(Section section) {
                return null;
            }

            @Override
            public Result<Void> savePPT(Ppt ppt) {
                return null;
            }

            @Override
            public Result<Void> saveHandouts(Handouts handouts) {
                return null;
            }

            @Override
            public Result<Void> saveExperiment(Experiment experiment) {
                return null;
            }

            @Override
            public Result<Void> saveRethink(Rethink rethink) {
                return null;
            }

            @Override
            public Result<CourseOutline> getCourseOutline(String courseId) {
                return null;
            }

            @Override
            public Result<Course> getCourseById(String id) {
                return null;
            }

            @Override
            public Result<Page<QuestionVo>> getQuestionsByHomeworkId(String homeworkId, Integer pageNum, Integer pageSize) {
                return null;
            }
//            @Override
//            public Result<Teacher> getTeacherById(String id) {
//                    if (cause instanceof TimeoutException) {
//                        return Result.error(504, "获取教师信息超时");
//                    } else if (cause instanceof ConnectException) {
//                        return Result.error(503, "教师服务暂时不可用");
//                    } else {
//                        return Result.error(500, "获取教师信息失败");
//                    }
//                log.error("ai模块调用teacher模块保存ai生成数据进数据库调用异常，异常原因：", cause);  //500
//                    return Result.error(CodeStatus.INTERNAL_SERVER_ERROR.getCode(), CodeStatus.INTERNAL_SERVER_ERROR.getMessage());
//                return Result.error(CodeStatus.INTERNAL_SERVER_ERROR.getCode(), "老师微服务暂时不可用");
//            }
        };
    }
}
